<?php
declare(strict_types=1);

namespace app\shop\logic;

use app\shop\model\advert\BannerModel;
use app\shop\model\advert\CollegeModel;
use app\shop\model\advert\HotRecommendModel;
use app\shop\model\advert\NoticeBarModel;
use app\shop\model\BaseModel;
use think\Collection;

class AdvertLogic extends BaseLogic
{
    /**
     * 轮播图列表
     * @return array|Collection
     */
    public function bannerList(): Collection|array
    {
        $query = BannerModel::getQuery();

        $query->where([
            ['status', '=', 1]
        ]);

        $query->field(['image', 'jump', 'goods_id']);

        $query->order(['weigh' => 'desc']);

        return BannerModel::listQuery($query);
    }

    /**
     * 公告栏列表
     * @return array|Collection
     */
    public function noticeBarList(): Collection|array
    {
        $query = NoticeBarModel::getQuery();

        $query->field(['id', 'title', 'content']);

        $query->where('status', 1);

        $query->order('weigh', 'desc');

        return BaseModel::listQuery($query);
    }

    public function collegeList(): Collection|array
    {
        $collegeModel = new CollegeModel();
        $query = $collegeModel::getQuery();

        $query->field(['id', 'title', 'content']);

        $query->where('status', 1);

        $query->order('weigh', 'desc');

        return $collegeModel::listQuery($query);
    }

    /**
     * 热卖推荐列表
     * @return Collection|array
     */
    public function hotRecommendList(): Collection|array
    {
        $query = HotRecommendModel::getQuery();

        $query->field(['id', 'title', 'sub_title', 'tags', 'image', 'classify_id', 'goods_id']);

        $query->where('status', 1);

        $query->order('weigh', 'desc');

        return HotRecommendModel::listQuery($query);
    }
}